#!/bin/bash
# configure.sh
# Copyright (C) Vincenzo Tilotta 2011 <tailot@gmail.com>
#
# configure.sh is free software: you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# configure.sh is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the GNU General Public License for more details.

# You should have received a copy of the GNU General Public License along
# with this program.  If not, see <http://www.gnu.org/licenses/>.
listlibrary=( /usr/bin/openssl /usr/bin/python )
function CHECKLIBRARY(){
	for library in ${listlibrary[@]}
	do
		if [ ! -f $library ] ; then
			echo "Please install "$library
			exit
		fi
	done
}
CHECKLIBRARY
#Genera una chiave rsa con il suo certificato
function GENRSA() {
	openssl genrsa 1024 > key
	openssl req -new -x509 -nodes -sha1 -days 365 -key key > cert
}

if [ $# -eq 0 ] ; then
		GENRSA
		mkdir web/users
		echo "Perfect!"
	elif [ $# -eq 1 ] ; then
		if [ $1 == "clean" ] ; then
			rm -frv *.pyc web/users key cert nebulosa_cc.tar.bz2 .nebulosa
		elif [ $1 == "tar" ] ; then
			tar -cjvf nebulosa_cc.tar.bz2 *
		fi
fi

